<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start(); //we need to call PHP's session object to access it through CI
class Home extends CI_Controller {
 
 function __construct()
 {
   parent::__construct();
 }
 
 function index()
 {
   if($this->session->userdata('logged_in'))
   { $session_data = $this->session->userdata('logged_in');
     //$data['status'] = $session_data['status'];
     $data['username'] = $session_data['username'];
       $data['firstname'] = $session_data['firstname'];
       $data['lastname'] = $session_data['lastname'];


            if($data['status']=="admin"){
            $this->load->view('header', $data);
            $this->load->view('sidebar_admin');
            $this->load->view('index_admin');
            $this->load->view('footer');

            }elseif($data['status']=="user"){

            $this->load->view('header', $data);
            $this->load->view('sidebar_user');
            $this->load->view('index_user');
            $this->load->view('footer');

            }elseif($data['status']=="supervisor"){


            $this->load->view('header', $data);
            $this->load->view('sidebar_supervisor');
            $this->load->view('index_supervisor');
            $this->load->view('footer');

            }else
               {
                 //If no session, redirect to login page
                 redirect('login', 'refresh');
               }

   }else {
                 //If no session, redirect to login page
                 redirect('login', 'refresh');
        }
 }
 
 function logout()
 {
   $this->session->unset_userdata('logged_in');
   session_destroy();
   redirect('home', 'refresh');
 }
 
}
 
?>